package com.chuanyang.driverh.mainother;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chuanyang.driverh.R;
import com.chuanyang.driverh.mainother.adapter.LookPicAdapter;
import com.chuanyang.driverh.utils.widget.photoview.HackyViewPager;

import java.util.ArrayList;

public class LookPicActivity extends Activity implements View.OnClickListener {
    private ArrayList<String> imagepath;
    private int index;
    private TextView tv_delete;
    private HackyViewPager viewPager;
    private ImageView iv_back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.order_act_lookpic);
        initView();
    }




    public void initView() {
        Intent intent = getIntent();
        imagepath = (ArrayList<String>) intent.getSerializableExtra("imagepaths");
        index = intent.getIntExtra("index", 0);
        viewPager = (HackyViewPager) findViewById(R.id.viewPager);
        tv_delete = (TextView) findViewById(R.id.tv_lookpic_delete);
        iv_back = (ImageView) findViewById(R.id.iv_caridentification_back);
        LookPicAdapter adpter = new LookPicAdapter(this, imagepath);
        viewPager.setAdapter(adpter);
        //默认选中那一张
        viewPager.setCurrentItem(index);
        tv_delete.setOnClickListener(this);
        iv_back.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId())
        {
            case  R.id.tv_lookpic_delete:
                Intent intent=new Intent();
                intent.putExtra("position",viewPager.getCurrentItem());
                setResult(1,intent);
                finish();

                break;
            case  R.id.iv_caridentification_back:
                finish();
                break;
        }
    }
}
